using System;
using System.Collections.Generic;
using Company.Infrastructure;
using Company.Model;
using Company.Model.Repository;
using Company.Model.Services;
using Company.Repository;

namespace Company.Services
{
    public class UsersService : IUsersService
    {
        private List<RuleViolations> m_RuleViolations = new List<RuleViolations>();

        private IUsersRepository m_UsersRepository =  new UsersRepository();

        public IUsers GetUser(int id)
        {
            return m_UsersRepository.GetUser(id);
        }

        public IUsers GetUser(string username)
        {
            return m_UsersRepository.GetUser(username);
        }

        public IUsers GetUser(string username, string password)
        {
            IUsers user = GetUser(username);
            if (user!=null)
            {
                if (user.Password == password)
                {
                    return user;
                }
            }
            m_RuleViolations.Add(new RuleViolations(ValidationErrors.LoginUserIncorrect));
            return null;
        }

        public IList<IDepartamento> RetDep()
        {
            return m_UsersRepository.fff();
        }

        public List<RuleViolations> GetRuleViolations()
        {
            return m_RuleViolations;
        }


    }
}